/**
 * 
 */
package com.google.code.seditor.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author zhangchao
 *
 */
public class DBHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION=2;
    private static final String DATABASE_NAME = "sEditorDB";
    private static final String DATABASE_CREATE =
        "create table fileinfo (_id integer primary key autoincrement, "
        + "title text not null, path text not null);";
    //private static final String DATABASE_TABLE = "notes";
    //private static final String FILE_TBL_NM="fileinfo";
	
	public DBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
	
//	public DBHelper(Context context, String name, CursorFactory factory,
//			int version) {
//		super(context, name, factory, version);
//		// TODO Auto-generated constructor stub
//	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);

	}

	/* (non-Javadoc)
	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w("DBHelper", "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS fileinfo");
        onCreate(db);

	}

}
